<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ taglib uri="/struts-tags" prefix="s"%>
 <jsp:include page="common/head.jsp"/>

<body>
<!-- Wrapper -->
<div id="wrapper_sec">
	<!-- Header -->
	<!--navigation part   -->
	<jsp:include page="common/navigation.jsp" />
    
    <div class="clear"></div>
    <div id="crumb">
    	<ul>
        	<li><a href="index.action">首页</a></li>
            <li class="last"><a href="#" class="colr bold">修改密码</a></li>
        </ul>
    </div>
    <div class="clear"></div>
    <!-- Content Section -->
    <div id="content_sec">
    	<!-- Column 1 -->
        <div class="col1">
        	<!-- Shop By Price -->
            <div class="byprice">
            	<h5 class="colr">MY ACCOUNT CENTER</h5>
                <ul>
                	<li><a href="myAccount.action" >我的订单</a></li>
                    <li><a href="myConsumerRecords.action">我的消费记录</a></li>
                    <li><a href="myRecentlyViewed.action">我最近浏览</a></li>
                    <li><a href="myFavorites.action">我的收藏夹</a></li>
                    <li><a href="myIntegral.action">我的积分</a></li>
                    <li><a href="myInfo.action">账户信息</a></li>
                    <li><a href="updateUserPassword.action">修改密码</a></li>
                </ul>
            </div>
            <div class="clear"></div>
            <div class="clear"></div>
        </div>
        <!-- Column 2 -->
        <div class="col2">    
                <!-- My Account -->
            	<div class="account">
                	<h4 class="colr bold smallheading upper"><span class="arrow">update password</span></h4>
                    <div class="accinner">
                    <div class="recentorders">
                    <div class="account_table">
                    <form id="myInfo_form">
		             <table border="0" cellpadding="0" cellspacing="0">
		                            
				         <tbody>
				             <tr>
					           <th align="left"><font size="3">用户基本信息</font> </th>
					         </tr>
					         <tr>
					                
					           <th>  <span class="txt">旧密码：<font color="red">*</font></span></th>
					           <td>
					           	<input id="oldPassword" name="user.oldPassword" type="password" class="inputSize" /><span id="oldPasswordInfo" style="display:none" ><font color="red">请填写旧密码</font></span>
					           </td>
					         </tr>
					         
					         <tr>
					           <th>  <span class="txt">新密码：<font color="red">*</font></span></th>
					           <td><input id="password" name="user.password" type="password" class="inputSize" /><span id="passwordInfo" style="display:none" ><font color="red">请填写新密码</font></span></td>
					         </tr>
					         <tr>
					           <th>  <span class="txt">确认密码：<font color="red">*</font></span></th>
					           <td><input id="confirmPassword" type="password" class="inputSize" /><span id="confirmPasswordInfo" style="display:none"><font color="red">新密码与旧密码不一致</font></span></td>
					         </tr>
					         
					         <tr>
					           <th><br/><br/></th>
					         </tr>
				         </tbody>
		       			 </table>
		       			  <hr/>
				      	  <hr/>
				          <hr/>
				       	   <div align="right"> <a href="#" id="updateInfoBtn" class="addOrderBtn">提交</a></div>
		       			 </form>
                    </div>
                    
                    <div class="clear"></div>
              
                    <div class="clear"></div>
                	</div>
                </div>
                
        </div>
        <div class="clear"></div>
        <hr/>
        
		  <div class="relateditems">
                	<h6 class="bold colr relhead">根据您的购买记录，我们为您推荐</h6>
                    <a href="#" class="leftarrow">&nbsp;</a>
                	<ul>
                    	<li>
                        	<div class="thumb">
                            	<a href="detail.html"><img src="images/rel1.gif" alt="" /></a>
                            </div>
                            <div class="desc">
                            	<h6><a href="detail.html" class="colr bold">Lorum Ipsum Dolor</a></h6>
                                <div class="rating">
                                    <div class="stars">
                                        <a href="#">&nbsp;</a>
                                        <a href="#">&nbsp;</a>
                                        <a href="#">&nbsp;</a>
                                        <a href="#">&nbsp;</a>
                                        <a href="#" class="gry">&nbsp;</a>
                                    </div>
                                    <a href="#" class="reviews">1 Review(s)</a>
                                </div>
                                <div class="prices">
                                    <p class="newprice colr bold">$58.00</p>
                                    <p class="oldprice">$88.00</p>
                                </div>
                                <div class="cartse">
                                    <a href="cart.html" class="buttonone">Add to Cart</a>
                                    <a href="#" class="whishlist">&nbsp;</a>
                                    <a href="#" class="favo">&nbsp;</a>
                                </div>
                            </div>
                        </li>
                        <li>
                        	<div class="thumb">
                            	<a href="detail.html"><img src="images/rel1.gif" alt="" /></a>
                            </div>
                            <div class="desc">
                            	<h6><a href="detail.html" class="colr bold">Lorum Ipsum Dolor</a></h6>
                                <div class="rating">
                                    <div class="stars">
                                        <a href="#">&nbsp;</a>
                                        <a href="#">&nbsp;</a>
                                        <a href="#">&nbsp;</a>
                                        <a href="#">&nbsp;</a>
                                        <a href="#" class="gry">&nbsp;</a>
                                    </div>
                                    <a href="#" class="reviews">1 Review(s)</a>
                                </div>
                                <div class="prices">
                                    <p class="newprice colr bold">$58.00</p>
                                    <p class="oldprice">$88.00</p>
                                </div>
                                <div class="cartse">
                                    <a href="cart.html" class="buttonone">Add to Cart</a>
                                    <a href="#" class="whishlist">&nbsp;</a>
                                    <a href="#" class="favo">&nbsp;</a>
                                </div>
                            </div>
                        </li>
                        <li class="last">
                        	<div class="thumb">
                            	<a href="detail.html"><img src="images/rel1.gif" alt="" /></a>
                            </div>
                            <div class="desc">
                            	<h6><a href="detail.html" class="colr bold">Lorum Ipsum Dolor</a></h6>
                                <div class="rating">
                                    <div class="stars">
                                        <a href="#">&nbsp;</a>
                                        <a href="#">&nbsp;</a>
                                        <a href="#">&nbsp;</a>
                                        <a href="#">&nbsp;</a>
                                        <a href="#" class="gry">&nbsp;</a>
                                    </div>
                                    <a href="#" class="reviews">1 Review(s)</a>
                                </div>
                                <div class="prices">
                                    <p class="newprice colr bold">$58.00</p>
                                    <p class="oldprice">$88.00</p>
                                </div>
                                <div class="cartse">
                                    <a href="cart.html" class="buttonone">Add to Cart</a>
                                    <a href="#" class="whishlist">&nbsp;</a>
                                    <a href="#" class="favo">&nbsp;</a>
                                </div>
                            </div>
                        </li>
                    </ul>
                    <a href="#" class="rightarrow">&nbsp;</a>
                    <div class="clear"></div>
              
                    </div>
</div>
        
    </div>
    <div class="clear"></div>
    <!-- Footer -->
      <jsp:include page="common/bottom.jsp"/>
    <div class="clear"></div>
</div>
</body>
</html>
 <script>
 $(document).ready(function() {
      
      $("#updateInfoBtn").click(function(){
    	  
    	  var oldPassword=$("#oldPassword").val();
    	  
    	  if(oldPassword.length==0&&oldPassword==''){
    		  $("#oldPasswordInfo").show();
    	  }
    	  
    	  $("#oldPassword").click(function(){
    		  $("#oldPasswordInfo").hide();
    	  });
    	  
 		  var password=$("#password").val();
    	  
    	  if(password.length==0&&password==''){
    		  $("#passwordInfo").show();
    	  }
    	  
    	  $("#password").click(function(){
    		  $("#passwordInfo").hide();
    	  });
    	  
		 var confirmPassword=$("#confirmPassword").val();
    	  
    	  if(confirmPassword.length==0&&confirmPassword==''){
    		  $("#confirmPasswordInfo").show();
    	  }
    	  
    	  $("#confirmPassword").click(function(){
    		  $("#confirmPasswordInfo").hide();
    	  });
    	  
    	  
    	  if(oldPassword.length>0&&oldPassword!=''&&password.length>0&&password!=''&&confirmPassword.length>0&&confirmPassword!=''){
    		  
              jQuery.ajax({
  				type : "post",
  				url : "userJson_updateUserPassword.action",
  				dataType : 'text',
  				data : $('#myInfo_form').serialize(),
  				success : function(json) {

  					if (json != null && json != '') {
  						var member = eval(json); //包数据解析为json 格式
  						var jsons = member.split("*");
  						if (jsons[0] == "true") {
  							alert('修改成功!');
  							window.self.location="toLogin.action";
  							
  						} else {
  							if (undefined != jsons[1]) {
  								if('login'==jsons[1]){
  									alert('请还没有登录，请登录');
  									window.self.location="toLogin.action";
  								}else{
  									alert(jsons[1]);
  								}
  							} else {
  								alert("修改失败！");
  							}
  						}
  					} else {
  						alert("异步处理异常，返回值为空！");
  					}
  				}
  			});
    		  
    		  
    	  }
    	  
      });
      
      
      
 
 });
 
 
 </script>